package co.com.services.sede;

import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import co.com.smart.maestro.infraestructure.dto.SedeDTO;
import co.com.smart.session.DelegateContextEJB;

@Path("/SmartSedeService")
public class SedeServices {

		@GET
		@Path("/getAllSede")	
		@Produces(MediaType.APPLICATION_JSON)
		public Response getSede() throws NamingException {
			return Response.ok(DelegateContextEJB.getSedeBeanLocal().consultarAllSede())
			.header("Access-Control-Allow-Origin", "*")
			.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
			.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}
		
		@POST
		@Path("/getSede")	
		@Produces(MediaType.APPLICATION_JSON)
		public Response getSede(SedeDTO json) throws NamingException {
			return Response.ok(DelegateContextEJB.getSedeBeanLocal().consultarAllSede(json))
			.header("Access-Control-Allow-Origin", "*")
			.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
			.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}

		@POST
		@Path("/getSedeId")	
		@Produces(MediaType.APPLICATION_JSON)
		public Response getSedeId(SedeDTO json) throws NamingException {
			return Response.ok(DelegateContextEJB.getSedeBeanLocal().consultarSedeId(json))
			.header("Access-Control-Allow-Origin", "*")
			.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
			.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}

		@PUT
		@Path("/setSede")
		@Consumes(MediaType.APPLICATION_JSON)
		@Produces(MediaType.APPLICATION_JSON)
		public Response setSede( SedeDTO json){ 
			return Response.ok(DelegateContextEJB.getSedeBeanLocal().insertarSede(json))
					.header("Access-Control-Allow-Origin", "*")
					.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
					.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With")
					.build();
		}

		@PUT
		@Path("/editSede")
		@Consumes(MediaType.APPLICATION_JSON)
		@Produces(MediaType.APPLICATION_JSON)
		public Response setEditSede(SedeDTO json){ 
			return Response.ok(DelegateContextEJB.getSedeBeanLocal().editSede(json))
			.header("Access-Control-Allow-Origin", "*")
			.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
			.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}

		@PUT
		@Path("/removeSede")
		@Consumes(MediaType.APPLICATION_JSON)
		@Produces(MediaType.APPLICATION_JSON)
		public Response setRemoveSede(SedeDTO json){ 
			return Response.ok(DelegateContextEJB.getSedeBeanLocal().removeSede(json, true))
					.header("Access-Control-Allow-Origin", "*")
					.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
					.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}



	}